//
//  AnnouncementDetailViewController.m
//  Kjs-iOS
//
//  Created by Pat on 16/8/5.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "AnnouncementDetailViewController.h"
#import "GUATool.h"
@interface AnnouncementDetailViewController ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIWebView *detailView;

@end

@implementation AnnouncementDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"消息详情";
    
    //时间戳转时间
    NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY-MM-dd hh:mm";
    //除以一千。时间戳后面有三个零？
    NSString * time = [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:self.messageDetail.createdTxStamp.integerValue/1000]];
    [self.timeLabel setText:time];
    
    switch (self.announcementType) {
        case 0:
            [self.titleLabel setText:[NSString stringWithFormat:@"%@", self.messageDetail.userMessageTitle]];
            [self.detailView loadHTMLString:[GUATool stringFromHTMLString:self.messageDetail.userMessageContent] baseURL:nil];
            break;
        case 1:
        case 2:
            [self.titleLabel setText:[NSString stringWithFormat:@"%@", self.newsDetail.title]];
            [self.detailView loadHTMLString:[GUATool stringFromHTMLString:self.newsDetail.content] baseURL:nil];
            break;
        default:
            break;
    }
    self.detailView.backgroundColor = [UIColor whiteColor];
}
@end
